{extend name="layout"/}

{block name="breadcrumb"}
<h2>语种列表</h2>
<ol class="breadcrumb">
    <li><a href="{:url('index/index')}">首页</a></li>
    <li><strong>语种列表</strong></li>
</ol>
{/block}

{block name="search"}
{include file='lang/search'/}
{/block}

{block name="main"}
<div class="ibox float-e-margins">
    <div class="ibox-title">
        <h5>语种列表</h5>
    </div>
    <div class="ibox-content">
        <p>
            <a href="{:url('form')}" class="btn btn-primary btn-sm"><i class="fa fa-plus-circle"></i> 添加语种</a>
            <button class="btn btn-danger btn-sm" onclick="actionAll('{:url("disables", ['status' => 0])}')">批量禁用</button>
            <button class="btn btn-primary btn-sm" onclick="actionAll('{:url("disables", ['status' => 1])}')">批量启用</button>
        </p>
        <div class="table-responsive table-elem">
            <p>共 {$count} 条数据</p>
            <table class="table table-striped">
                <thead>
                <tr>
                    <th class="checkbox-th">
                        <div class="checkbox checkbox-primary">
                            <input id="checkbox-all" type="checkbox">
                            <label for="checkbox-all"></label>
                        </div>
                    </th>
                    <th>ID</th>
                    <th>语种</th>
                    <th>权重</th>
                    <th>状态</th>
                    <th>初级班价格</th>
                    <th>中级班价格</th>
                    <th>高级班价格</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {foreach $model as $key=>$vo }
                <tr>
                    <td>
                        <div class="checkbox checkbox-primary">
                            <input id="checkbox{$vo.id}" type="checkbox" value="{$vo.id}" class="checkbox-item">
                            <label for="checkbox{$vo.id}"></label>
                        </div>
                    </td>
                    <td>{$vo.id}</td>
                    <td>{$vo.name}</td>
                    <td>{$vo.sort_num}</td>
                    <td>
                        <span class="label {$vo.status == 1 ? 'label-info' : 'label-danger'}">{$vo.statusText}</span>
                    </td>
                    <td>{$vo.class_1}</td>
                    <td>{$vo.class_2}</td>
                    <td>{$vo.class_3}</td>
                    <td>{$vo.create_time}</td>
                    <td>
                        {foreach $course as $class=>$c}
                        {php}
                        if ($class == 1) {
                            $classId = $vo['class_1_id'];
                        } elseif ($class == 2) {
                            $classId = $vo['class_2_id'];
                        } else {
                            $classId = $vo['class_3_id'];
                        }
                        {/php}

                        <select data-id="{$classId}" data-class="{$c.className}" data-lang="{$vo.name}" class="select-course">
                            <option value="-1">{$c.className}</option>
                            {foreach $c.course as $k=>$v}
                            <option value="{$v.type}">{$v.name}</option>
                            {/foreach}
                        </select>
                        {/foreach}

                        <a href="{:url('form', ['id' => $vo.id])}" class="btn btn-success btn-xs">编辑</a>
                        <a href="javascript:void(0);" data-id="{$vo.id}" class="disabled-one btn btn-warning btn-xs">{$vo.status == 1 ? '禁用' : '启用'}</a>
                        <a href="javascript:void(0);" data-id="{$vo.id}" class="delete-one btn btn-danger btn-xs">删除</a>
                    </td>
                </tr>
                {/foreach}
                </tbody>
            </table>
            {$model|raw}
        </div>

    </div>
</div>
{/block}

{block name="jsFile"}
<script>
    // 点击语音课等跳转页面
    $('.select-course').change(function () {
        let classId = $(this).data('id');
        let courseType = $(this).val();
        let lang = $(this).data('lang');
        let className = $(this).data('class');
        if (classId > 0 && courseType > 0) {
            let url_tmp = "{:url('lang_class_file/index', ['classId' => '__CLASS_ID__', 'courseType' => '__COURSE_TYPE__', 'type' => 1, 'lang' => '__LANG__', 'className' => '__CLASS_NAME__'])}";
            let url_tmp2 = url_tmp.replace('__CLASS_ID__', classId);
            let url_tmp3 = url_tmp2.replace('__LANG__', lang);
            let url_tmp4 = url_tmp3.replace('__CLASS_NAME__', className);
            let url = url_tmp4.replace('__COURSE_TYPE__', courseType);
            window.location.href = url;
        }
    });
</script>
{/block}